package com.trend.job;

import java.util.Date;
import java.util.List;

import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;

import com.trend.pojo.Index;
import com.trend.service.IndexDataService;
import com.trend.service.IndexService;

public class IndexDataSyncJob extends QuartzJobBean {

	@Autowired
	IndexService indexService;
	@Autowired
	IndexDataService indexDataService;

	@Override
	protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
		System.out.println("定时任务开始启动：" + new Date());
		List<Index> indexes = indexService.fresh();

		for (Index index : indexes) {
			String code = index.getCode();
			indexDataService.fresh(code);
		}
		System.out.println("定时任务结束：" + new Date());
	}

}
